package com.rowline.admin.module.study.postprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;

/**
 * ClassName:SaveStudentsService
 * Created by 245167
 * on 2018/4/27  27:13
 * description:
 */
public class SaveStudentsService implements BeanFactoryAware, BeanNameAware,InitializingBean, DisposableBean {

    private String name;

    private String sex;

    public void setName(String name) {
        System.out.println("【属性注入】names");
        this.name = name;
    }

    public void setSex(String sex) {
        System.out.println("【属性注入】sex");
        this.sex = sex;
    }

    public SaveStudentsService() {
        System.out.println("【构造函数】SaveStudentsService()");
    }

    public void init() {
        System.out.println("【init-method】");
    }

    public void close() {
        System.out.println("【destroy-method】");
        System.out.println("=============================================================");
    }

    public void saveStudent(){
        System.out.println("【bean使用】");
        System.out.println("保存学生信息成功");
        System.out.println("操作人name:" + name + ", sex:" + sex);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("【BeanFactoryAware】 setBeanFactory()");
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("【BeanNameAware】 BeanNameAware()");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("=============================================================");
        System.out.println("【InitializingBean】 afterPropertiesSet()");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("【DisposableBean】 destroy()");
    }
}
